﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Whir.Common.WebHelper;

public partial class Whir_System_Module_Survey_Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindData();
        }
    }

    private void BindData()
    {
        DataSet ds = Whir.SQLServerDAL.DbHelperSQL.GetList("Whir_Survey", "SurveyID", "*", AspNetPager1.PageSize, AspNetPager1.CurrentPageIndex - 1, "", "", "CreateDate desc");
        int rowCount = int.Parse(ds.Tables[1].Rows[0][0].ToString());
        if (rowCount > 0)
        {
            AspNetPager1.RecordCount = rowCount;
            GridView1.DataSource = ds;
            GridView1.DataBind();
        }
        else
        {
            GridView1.Controls.Clear();
            divMessage.Visible = true;
        }
    }

    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        BindData();
    }

    protected void btnDelete_Click(object sender, EventArgs e)
    {
        Whir.BLL.Whir_Survey bll = new Whir.BLL.Whir_Survey();
        //获取被选中的编号
        int[] itemIds = this.GridView1.CheckedIndexs;
        if (itemIds.Length > 0)
        {
            foreach (int item in itemIds)
            {
                bll.Delete(item);
            }
            JsHelper.Alert(Page, "该记录已删除成功！");
            BindData();
        }
        else
        {
            JsHelper.Alert(Page, "请选择要删除的记录！");
        }
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Redirect("SurveyAdd.aspx?Action=Add");
    }
}
